package com.simple.cms.common.result;


import com.baomidou.mybatisplus.plugins.Page;

import java.util.ArrayList;
import java.util.List;

public class PageListResult<T> extends CommonResult {
    private static final long serialVersionUID = 1027501667691265867L;

    /**
     * 是否有下一页
     */
    private boolean hasNextPage;

    /**
     * 页码
     */
    private int pageNum;

    /**
     * 每页大小
     */
    private int pageSize;

    /**
     * 总记录数
     */
    private int total;

    /**
     * 总页数
     */
    private int pages;

    /**
     * 当前页记录数
     */
    private int size;

    private List<T> dataList = new ArrayList<T>();

    public PageListResult(List<T> dataList, Page<T> page) {
        super();
        setDataList(dataList);
        this.hasNextPage = page.hasNext();
        this.pageNum = page.getCurrent();
        this.pageSize = page.getSize();
        this.total = page.getTotal();
        this.pages = page.getPages();
        this.size = page.getRecords().size();
    }

    public boolean isHasNextPage() {
        return hasNextPage;
    }

    public void setHasNextPage(boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }
}
